﻿Imports System
Imports System.Configuration

Namespace DAL
    Public Class ConfigManager
        Private Shared Function GetConfiguracion() As Configuration
            Dim mPath As String
            Dim mConfig As Configuration

            mPath = IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppDomain.CurrentDomain.FriendlyName)
            mConfig = ConfigurationManager.OpenExeConfiguration(mPath)

            Return mConfig

        End Function

        Public Shared Function GetValue(ByVal pKey As String) As String
            Dim mConfig As Configuration
            Dim mValue As String

            Try
                mConfig = GetConfiguracion()
                Try
                    mValue = mConfig.AppSettings.Settings(pKey).Value
                    Return mValue
                Catch ex As Exception
                    MsgBox("Falta la key: " & pKey & ", " & ex.Message)
                End Try

            Catch ex As Exception
                MsgBox(ex.Message)
            Finally
                mConfig = Nothing
            End Try

        End Function
    End Class
End Namespace

